import os
import sys
import util        

import services

if __name__ == "__main__":
    print "Starting RPC service..... "
    server = util.startServer()
    
    rpc_pid = os.getpid()

    rpc_server_pid_file_path = os.path.expanduser(os.path.join("~","db","rpc_server.pid"))
    
    rpc_server_pid_file = open(rpc_server_pid_file_path, "w")
    rpc_server_pid_file.write(str(rpc_pid))
    rpc_server_pid_file.close()

    print "pid {0} written to pid file {1}".format(rpc_pid, rpc_server_pid_file_path) 

    rpc_service = services.BasicService()
    services.launch_service(rpc_service, "rpcservice")
    
                                       

                                   


